<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <button id="btn">设置段落颜色</button>
    <hr />
    <p>段落1</p>
    <p>段落2</p>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script>
      $('#btn').click(function () {
        $('p').css('color', function (index, value) {
          console.log('遍历元素', index, value)
          /*
          0 rbg(0,0,0)
          1 rbg(0,0,0)
          */
          return 'red'
        })
      })
    </script>
  </body>
</html>
